package com.cefa.finance.service;

import com.cefa.finance.config.AdminApplicationRunner;
import com.cefa.finance.dao.AccountRepository;
import com.cefa.finance.model.Account;
import com.cefa.finance.utils.MD5Generator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class LoginService {

    private final static Logger logger = LoggerFactory.getLogger(LoginService.class);

    @Autowired
    private AccountRepository accountRepository;

    @Autowired
    private AdminApplicationRunner adminApplicationRunner;

    public Account getAccount(Account source) {
        try {
            adminApplicationRunner.run();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return accountRepository.findByAccountAndPassword(source.getUserAccount(), MD5Generator.generatorMD5(source.getPassword()));
    }
}


















